#pragma once

#include "sys/typedef.h"

class PresentationContext
{
public:
	PresentationContext()
		:m_target(NULL),
		m_presentOption(0U)
	{}
	virtual ~PresentationContext(){}
	PresentationContext(IObject* target)
		:m_target(target),
		 m_presentOption(0U)
	{}

	void SetTarget(IObject* value) {m_target = value;}
	IObject*  GetTarget() const{return m_target;}
	vclsid GetTargetClsid() const{return m_target->GetClassID();}

	ulong GetPresentOption() const{return m_presentOption;}
	void SetPresentOption(ulong option){m_presentOption = option;}
	bool IsOptionDisabled(ulong optionflag) const{return ((m_presentOption&optionflag)!=optionflag);}
	bool IsOptionEnabled(ulong optionflag) const{return ((m_presentOption&optionflag)==optionflag);}
	void EnableOption(ulong optionflag){m_presentOption |= optionflag;}
	void DisableOption(ulong optionflag){m_presentOption &= ~optionflag;}
	void EnableOption(ulong optionflag,bool enable)
	{
		if (enable)	EnableOption(optionflag);
		else	DisableOption(optionflag);
	}

private:
	IObject* m_target;
	ulong m_presentOption;
};

#undef ENABLE_PRESENTENT_OPTION_1
#undef ENABLE_PRESENTENT_OPTION_2
#undef ENABLE_PRESENTENT_OPTION_3
#undef ENABLE_PRESENTENT_OPTION_4

#undef DISABLE_PRESENTENT_OPTION_1
#undef DISABLE_PRESENTENT_OPTION_2
#undef DISABLE_PRESENTENT_OPTION_3
#undef DISABLE_PRESENTENT_OPTION_4

#undef ENABLE_DISABLE_PRESENTENT_OPTION_1
#undef ENABLE_DISABLE_PRESENTENT_OPTION_2
#undef ENABLE_DISABLE_PRESENTENT_OPTION_3
#undef ENABLE_DISABLE_PRESENTENT_OPTION_4

#define ENABLE_PRESENTENT_OPTION_1(context,opt1)	\
	context.EnableOption(opt1);
#define ENABLE_PRESENTENT_OPTION_2(context,opt1,opt2)	\
	ENABLE_PRESENTENT_OPTION_1(opt1) context.EnableOption(opt2);
#define ENABLE_PRESENTENT_OPTION_3(context,opt1,opt2,opt3)	\
	ENABLE_PRESENTENT_OPTION_2(opt1,opt2) context.EnableOption(opt3);
#define ENABLE_PRESENTENT_OPTION_4(context,opt1,opt2,opt3,opt4)	\
	ENABLE_PRESENTENT_OPTION_3(opt1,opt2,opt3) context.EnableOption(opt4);

#define DISABLE_PRESENTENT_OPTION_1(context,opt1)	\
	context.DisableOption(opt1);
#define DISABLE_PRESENTENT_OPTION_2(context,opt1,opt2)	\
	DISABLE_PRESENTENT_OPTION_1(opt1) context.DisableOption(opt2);
#define DISABLE_PRESENTENT_OPTION_3(context,opt1,opt2,opt3)	\
	DISABLE_PRESENTENT_OPTION_2(opt1,opt2) context.DisableOption(opt3);
#define DISABLE_PRESENTENT_OPTION_4(context,opt1,opt2,opt3,opt4)	\
	DISABLE_PRESENTENT_OPTION_3(opt1,opt2,opt3) context.DisableOption(opt4);

#define ENABLE_DISABLE_PRESENTENT_OPTION_1(context,opt1,enabled1)	\
	context.EnableOption(opt1,enabled);
#define ENABLE_DISABLE_PRESENTENT_OPTION_2(context,opt1,enabled1,opt2,enabled2)	\
	ENABLE_DISABLE_PRESENTENT_OPTION_1(opt1,enabled1) context.EnableOption(opt2,enabled2);
#define ENABLE_DISABLE_PRESENTENT_OPTION_3(context,opt1,enabled1,opt2,enabled2,opt3,enabled3)	\
	ENABLE_DISABLE_PRESENTENT_OPTION_2(opt1,enabled1,opt2,enabled2) context.EnableOption(opt3,enabled3);
#define ENABLE_DISABLE_PRESENTENT_OPTION_4(context,opt1,enabled1,opt2,enabled2,opt3,enabled3,opt4,enabled4)	\
	ENABLE_DISABLE_PRESENTENT_OPTION_3(context,opt1,enabled1,opt2,enabled2,opt3,enabled3) context.EnableOption(opt4,enabled4);